package com.jianyun.jyzs.activity.newsign;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jianyun.jyzs.R;
import com.jianyun.jyzs.bean.Sign2Bean;
import com.jianyun.jyzs.bean.SignNewReslut;
import com.jianyun.jyzs.utils.UtilsStyle;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by yangshijun on 2018/6/8.
 */

public class NewSignSuccessActivity extends AppCompatActivity {
    @BindView(R.id.topBack)
    ImageView topBack;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.iv_calendar)
    ImageView ivCalendar;
    @BindView(R.id.top_rl)
    RelativeLayout topRl;
    @BindView(R.id.sign_icon)
    ImageView signIcon;
    @BindView(R.id.tv_time)
    TextView tvTime;
    @BindView(R.id.tv_location)
    TextView tvLocation;
    @BindView(R.id.tv_daka)
    TextView tvDaka;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_sign_success);
        UtilsStyle.setStatusBarMode(this,true);
        ButterKnife.bind(this);
        SignNewReslut signReslut = (SignNewReslut) getIntent().getSerializableExtra("signReslut");
        Sign2Bean sign2Bean= (Sign2Bean) getIntent().getSerializableExtra("sign2Bean");
        int signStatusCode=-1;
        if (signReslut!=null){
            signStatusCode= signReslut.getSignStatusCode();

        }else if (sign2Bean!=null){
            signStatusCode=sign2Bean.getSignStatusCode();
        }
        if (1== signStatusCode) {
            signIcon.setImageResource(R.drawable.icon_sign_success);
            tvDaka.setText("打卡成功");
            tvDaka.setTextColor(getResources().getColor(R.color.zhengc));
        } else if (2 == signStatusCode) {
            signIcon.setImageResource(R.drawable.icon_sign_chidao);
            tvDaka.setText("迟到打卡");
            tvDaka.setTextColor(getResources().getColor(R.color.f333));
        } else if (3 == signStatusCode) {
            signIcon.setImageResource(R.drawable.icon_sign_zaotui);
            tvDaka.setText("早退打卡");
            tvDaka.setTextColor(getResources().getColor(R.color.f333));
        }
        if (signReslut!=null){
            tvLocation.setText(signReslut.getSignAddress());
            tvTime.setText(signReslut.getSignTime()+"");
        }
        if (sign2Bean!=null){
            tvLocation.setText(sign2Bean.getSignAddress());
            tvTime.setText(sign2Bean.getSignTime()+"");
        }

    }

    @OnClick({R.id.topBack, R.id.iv_calendar})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.topBack:
                finish();
                break;
            case R.id.iv_calendar:
                startActivity(new Intent(this, NewSignReCordActivity.class));
                finish();
                break;
        }
    }
}
